home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / SC #49.sit / Driver Code / Format_new.a < prev    next >
Text File  |  1988-01-06  |  3KB  |  130 lines

  1.                 TITLE            'Numeric formatting for pump driver'
  2.                 CASE            ON
  3.                 BLANKS            ON
  4.  
  5.                 PRINT            OFF
  6.                 INCLUDE         'Traps.a'
  7.                 INCLUDE         'ToolEqu.a'
  8.                 INCLUDE         'QuickEqu.a'
  9.                 INCLUDE         'SysEqu.a'
  10.                 LOAD            'ProgStrucMacs.d'
  11.                 LOAD            'FlowCtlMacs.d'
  12.                 PRINT            ON
  13.  
  14. ;
  15. ;    This subroutine takes the decoded pump request (a character) and the
  16. ;    pump info (a hex word), and returns a STR255 properly
  17. ;    formatted to send to the pump, given a pointer to put the string into.
  18.  
  19. EXPORT    Procedure    HexSet ( StringAddress:L , StringLength:L , PRqstStr:B , PInfo:W )
  20.  
  21.     Begin    Save=A0/D0-D2;
  22.  
  23.                 MOVE.L            StringAddress(FP),A0
  24.                 MOVE.W            PInfo(FP),D0
  25.                 MOVE.B            PRqstStr(FP),(A0)+
  26.                 MOVE.B            #'=',(A0)+
  27.                 For# D2 = #3 DownTo #0 Do.S
  28.                     LSL.L            #4,D0                    ;Grab next most significant nybble
  29.                     MOVE.L            D0,D1                    ;move to D1
  30.                     SWAP            D1                        ;put in low end of low word
  31.                     AND.W            #$F,D1                    ;mask off everything else
  32.                     MOVE.B            TableBase(D1),(A0)+        ;grab character from table
  33.                 EndF#
  34.                 MOVE.B            #13,(A0)+
  35.                 MOVE.B            #10,(A0)+
  36.                 
  37.                 MOVE.L            StringLength(FP),A0
  38.                 MOVE.L            #8,(A0)
  39.                 
  40.                 Return
  41.  
  42.                 STRING            ASIS                
  43. TableBase        DC.B            '0123456789ABCDEF'
  44.  
  45.                 ENDP
  46.  
  47. ;
  48. ;    This subroutine takes the decoded pump request (a character) and the
  49. ;    pump info (a decimal word), and returns a STR255 properly
  50. ;    formatted to send to the pump, given a pointer to put the string into.
  51.  
  52.                 MACRO
  53.                 NumToString
  54.                 LEA                TempString(FP),A0
  55.                 CLR.W            -(SP)
  56.                 _Pack7
  57.                 ENDM
  58.                 
  59.  
  60.                 MACRO
  61.                 MaxTheString
  62.                 LCLC        &MaxString
  63. &MaxString        SETC        &CONCAT(&CHR(4),'999')
  64.                 MOVE.L            #'&MaxString',TempString(FP)
  65.                 LEA                TempString(FP),A0
  66.                 ENDM
  67.  
  68.                 MACRO
  69.                 MinTheString
  70.                 LCLC        &MinString
  71. &MinString        SETC        &CONCAT(&CHR(1),'0')
  72.                 MOVE.W            #'&MinString',TempString(FP)
  73.                 LEA                TempString(FP),A0
  74.                 ENDM
  75.  
  76. EXPORT    Procedure    IntegerSet ( StringAddress:L , StringLength:L , PRqstStr:B , PInfo:W )
  77.  
  78.     Var        TempString:B[255]
  79.     Begin    Save=A0-A1/D2;
  80.  
  81.                 MOVE.W            PInfo(FP),D0
  82.                 
  83.                 If# D0 GT.W #999 Then.S
  84.                     MaxTheString
  85.                 ElseIf#.S D0 LE.W #0 Then.S
  86.                     MinTheString
  87.                 Else#.S
  88.                     NumToString
  89.                 EndIf#
  90.                 
  91.                 MOVE.B            (A0)+,D0
  92.                 EXT.W            D0
  93.                 MOVE.W            D0,D1
  94.                 SUBQ.W            #1,D0
  95.                 MOVE.L            StringAddress(FP),A1
  96.                 MOVE.B            PRqstStr(FP),(A1)+
  97.                 MOVE.B            #'=',(A1)+
  98.                 For# D0 DownTo #0 Do.S
  99.                     MOVE.B            (A0)+,(A1)+
  100.                 EndF#
  101.                 MOVE.B            #13,(A1)+
  102.                 MOVE.B            #10,(A1)+
  103.                 
  104.                 MOVE.L            StringLength(FP),A0
  105.                 ADDQ.W            #4,D1
  106.                 EXT.L            D1
  107.                 MOVE.L            D1,(A0)
  108.                 
  109.                 Return
  110.                 ENDP
  111.                 
  112. EXPORT    Procedure    AskFormat ( StringAddress:L , StringLength:L , PRqstStr:B )
  113.  
  114.     Begin    Save=A0;
  115.     
  116.                 MOVE.L            StringAddress(FP),A0
  117.                 MOVE.B            PRqstStr(FP),(A0)+
  118.                 MOVE.B            #'?',(A0)+
  119.                 MOVE.B            #13,(A0)+
  120.                 MOVE.B            #10,(A0)+
  121.  
  122.                 MOVE.L            StringLength(FP),A0
  123.                 MOVE.L            #4,(A0)
  124.                 
  125.                 Return
  126.                 ENDP
  127.  
  128.                 END
  129.  
  130.